<div class="nav-sub w1180">
	<ul class="zoom">
		<li><a class="on" href="/crm/material/catelog-list">溯源类型列表</a></li>
		<li><a href="/crm/material/cate-list">溯源类目列表</a></li>
		<li><a href="/crm/material/list">溯源列表</a></li>
		<li><a href="/crm/material/report-list">溯源报告列表</a></li>
	</ul>
</div>
<div class="main-ct w1180">
	<div class="top-bar">
		<div class="custom-search">
			<label>溯源类型
				<select class="category-select" id="material_catalog_id">
				
					<option value="">请选择</option>
					<?php if ($this->catelog):?>
    				<?php foreach ($this->catelog as $k=>$v):?>
        				<option value="<?php echo $v['material_catalog_id']; ?>"><?php echo $v['material_catalog_name']; ?></option>
        			<?php endforeach; ?>
    				<?php endif;?>
				</select>
			</label>
			<a href="javascript:search();" class="btn-cs btn-search ml5">查 询</a>
<!-- 			<a href="javascript:;" class="btn-cs btn-green ml5">输出报表</a> -->
		</div>
		<a class="btn-cs btn-fillet btn-green btn-add-catalog" href="/crm/material/add-catelog">新增类型</a>
	</div>
<div id="list-table"></div>
</div>

<script type="text/javascript">
    var material_catalog_id = $("#material_catalog_id").val();
    var page =1;
    
    $(document).ready(function(){
    	ajaxListTable();
    });
    
    function search(){
    	material_catalog_id = $("#material_catalog_id").val();
    
    	ajaxListTable();
    }
    
    function paginator(page_no) {
    	page = page_no;
    	ajaxListTable();
    }
    
    function ajaxListTable(){
    	$.ajax({
            type: "post",
            url: "<?php echo $this->url('crm/material',
                array('action'=>'ajax-material-catelog-list'));?>",
            dataType:'html',
            data: { "material_catalog_id": material_catalog_id,
    				"page":page
    		},
            cache: false,
            timeout:10000, 
            error: function(){
              	 alert('请求超时，请重新操作');
               	 isPost = false;
                 return false; 
             }, 
            success: function(html){
            	$("#list-table").html(html);
            }
        });
    }

// 	function showpop(){
// 		$('.bgMask,.popup-form').show();
// 	}
	
// 	function hidepop(){

// 		$('.bgMask,.popup-form').hide();
// 		$(".bgMask,.popup-form").remove();
// 	}

// 	$('.btn-add-catalog').click(function(){
//     	var html='';
//     	html += '<div class="bgMask"></div>'
//     		 + '<div class="popup popup-form">'
//     		 + '<h4 class="txt-center">新增类型</h4>'
//     		 + '<p><input type="text" id="catalog-name"></p>'
//     		 + '<p class="txt-center"><a href="javascript:addCatalog();" class="btn-cs btn-fillet btn-green mt20 btn-sub">确定</a></p>'
//     		 + '<a href="javascript:hidepop();" class="btn-close"></a>'
//     		 + '</div>';
//     		$('body').append(html);
//     		$('.bgMask,.popup-form').show();
// 	})
	
// 	function addCatalog(){
// 		var CatalogName = $("#catalog-name").val();
// 		var data = {'catalog_name':CatalogName};
// 		$.post("/crm/material/insertCatelog", data, response, 'json');
// 	}

//     function response(res){
//     	hidepop();
//         alert(res.reason);
//     }

</script>